package com.learning.springboot.springdataJpa;

import com.learning.springboot.Thymeleaf.entity.Person;
import org.springframework.data.jpa.domain.Specification;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

/**
 * Created by td on 2017/9/29.
 */
public class CustomerSpecsFind {

    public static Specification<Person> pesonFromtingdong(String name) {

            return new Specification<Person>() {
            @Override
            public Predicate toPredicate(Root<Person> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {

                return criteriaBuilder.equal(root.get("name"), name);
            }

        };
    }
}
